package com.cloudbroker.bcs.platform.ltb.middle.util;

import com.cloudbroker.bcs.common.util.DateTimeUtil;
import com.cloudbroker.bcs.platform.ltb.common.constant.CacheKeys;
import com.cloudbroker.bcs.platform.ltb.common.util.CacheHelper;

public class PositionStrUtil {
    
    public static String getPositionStr() {
        String seriaNo = CacheHelper.getInstance().get(CacheKeys.POSITION_STR_KEY_PREFIX);
        Integer temp = 0;
        if (seriaNo != null) {
            temp = Integer.valueOf(seriaNo);
        }
        temp++;
        if (temp > 9999) {
            temp = 1;
        }
        CacheHelper.getInstance().set(CacheKeys.POSITION_STR_KEY_PREFIX, temp.toString(), -1);
        seriaNo = temp < 10 ? "000" + temp : temp < 100 ? "00" + temp : temp < 1000 ? "0" + temp : temp.toString();

        return DateTimeUtil.getCurrentDateString(DateTimeUtil.FORMAT_YYYYMMDDHHMMSSSSS_NO_BREAK) + seriaNo;
    }
}
